﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Campus
{
    public class Tile
    {
        /// <summary>
        /// The texture to be used for drawing this Tile object.
        /// </summary>
        public Texture2D Texture
        {
            get { return m_texture; }
        }
        private Texture2D m_texture;

        /// <summary>
        /// The size (in pixels) of the area into which to draw this tile.
        /// </summary>
        public Vector2 DrawSize
        {
            get { return m_drawSize; }
        }
        private Vector2 m_drawSize;

        /// <summary>
        /// The color to tint this tile when it is drawn.
        /// </summary>
        public Color TintColor
        {
            get { return m_tintColor; }
        }
        private Color m_tintColor;

        /// <summary>
        /// Sprite Effects to be applied to the tile when drawn.
        /// </summary>
        public SpriteEffects Effects
        {
            get { return m_effects; }
        }
        private SpriteEffects m_effects;

        /// <summary>
        /// The position (in pixels) of the left-most corner of the tile as it appears in the texture for this Tile object.
        /// 
        /// The tile will be drawn from this position.
        /// </summary>
        public Vector2 Origin
        {
            get { return m_origin; }
        }
        private Vector2 m_origin;

        /// <summary>
        /// The z value given to this Tile when it gets drawn (0.0 = closest, 1.0 = furthest).
        /// </summary>
        public float LayerDepth
        {
            get { return m_layerDepth; }
        }
        private float m_layerDepth = -1.0f;

        /// <summary>
        /// Whether or not this tile can be walked
        /// </summary>
        public bool IsWalkable
        {
            get;
            private set;
        }

        /// <summary>
        /// The color that this tile will display when drawn on the minimap.
        /// </summary>
        public Color MinimapColor
        {
            get;
            private set;
        }

        /// <summary>
        /// Creates a Tile object from the parts necessary to draw a Sprite to the screen; automatically determines layer depth (z-value) when drawing.
        /// </summary>
        /// <param name="texture">The texture to be used for drawing this Tile object.</param>
        /// <param name="drawSize">The size (in pixels) of the area into which to draw this tile.</param>
        /// <param name="origin">The position (in pixels) of the left-most corner of the tile as it appears in the texture for this Tile object.</param>
        /// <param name="color">The color to tint this tile when it is drawn.</param>
        /// <param name="effects">Sprite Effects to be applied to the tile when drawn.</param>
        public Tile(Texture2D texture, Vector2 drawSize, Vector2 origin, Color color, SpriteEffects effects, bool isWalkable, Color minimapColor)
        {
            m_texture = texture;
            m_drawSize = drawSize;
            m_origin = origin;
            m_tintColor = color;
            m_effects = effects;
            IsWalkable = isWalkable;
            MinimapColor = minimapColor;
        }

        /// <summary>
        /// Creates a Tile object from the parts necessary to draw a Sprite to the screen; uses a provided layer depth (z-value).
        /// </summary>
        /// <param name="texture">The texture to be used for drawing this Tile object.</param>
        /// <param name="drawSize">The size (in pixels) of the area into which to draw this tile.</param>
        /// <param name="origin">The position (in pixels) of the left-most corner of the tile as it appears in the texture for this Tile object.</param>
        /// <param name="color">The color to tint this tile when it is drawn.</param>
        /// <param name="effects">Sprite Effects to be applied to the tile when drawn.</param>
        /// <param name="layerDepth">The z value given to this Tile when it gets drawn (0.0 = closest, 1.0 = furthest).</param>
        public Tile(Texture2D texture, Vector2 drawSize, Vector2 origin, Color color, SpriteEffects effects, bool isWalkable, Color minimapColor, float layerDepth)
        {
            m_texture = texture;
            m_drawSize = drawSize;
            m_origin = origin;
            m_tintColor = color;
            m_effects = effects;
            IsWalkable = isWalkable;
            m_layerDepth = layerDepth;
            MinimapColor = minimapColor;
        }
    }
}
